package com.app114.app.android.rk.webkit;

import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;

public class WebviewUtils {

	public static void webViewSettings(WebView webView) {
		webView.requestFocus() ;
		WebSettings settings = webView.getSettings();
		settings.setSupportZoom(true);
		settings.setJavaScriptCanOpenWindowsAutomatically(true);
		settings.setSupportMultipleWindows(true);
		settings.setPluginState(PluginState.ON);
		settings.setJavaScriptEnabled(true);
		settings.setLightTouchEnabled(true);
		settings.setUseWideViewPort(true);
//		settings.setGeolocationEnabled(true);

		// 在Android中构建离线应用
		settings.setAppCacheEnabled(true);
		settings.setDatabaseEnabled(true);
		settings.setDomStorageEnabled(true);
		//设置应用缓存的最大尺寸
		settings.setAppCacheMaxSize(1024 * 1024 * 8);
	}
	
	public static void simpleSettings(WebView webView) {
		WebSettings settings = webView.getSettings();
		settings.setJavaScriptCanOpenWindowsAutomatically(true);
		settings.setJavaScriptEnabled(true);
		settings.setLightTouchEnabled(true);
		settings.setUseWideViewPort(true);
		settings.setSupportZoom(false);
		settings.setAppCacheEnabled(true);
		settings.setDatabaseEnabled(true);
		settings.setDomStorageEnabled(true);
		settings.setPluginState(PluginState.ON);
		//设置应用缓存的最大尺寸
		settings.setAppCacheMaxSize(1024 * 1024 * 8);
	}

	public static void setBlockNetworkImage(WebView webView, boolean flag) {
		WebSettings settings = webView.getSettings();
		settings.setBlockNetworkImage(flag); // 打开图片,默认不堵塞
	}

	public static void setGeolocationEnabled(WebView webView, boolean flag) {
		WebSettings settings = webView.getSettings();
		settings.setGeolocationEnabled(flag);
	}

}
